/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020.
 * Description: support fiq_glue_private.h for x86
 * Author: yingelin <yingelin@huawei.com>
 * Create: 2020-10-21
 */
#ifndef FIQ_GLUE_PRIVATE_H
#define FIQ_GLUE_PRIVATE_H

#include <linux/list.h>
#include <asm/stacktrace.h>
#include <linux/hal/fiq_glue.h>
#include <linux/mutex.h>

#define FIQ_GLUE_PRIVATE_SZ 32
#define FIQ_FIRST_REGISTER 0
#define FIQ_ALREADY_REGISTER 1

struct fiq_priv_handle {
	int (*fiq_init_handle)(void);
	void (*fiq_cleansource_handle)(void);
	unsigned int (*fiq_get_source)(void);
	void (*fiq_post_callback)(void);
};

struct fiq_private_data {
	struct list_head entry;
	struct fiq_priv_handle callback;
};

struct fiq_num_node {
	struct list_head node;
	unsigned int fiq_num;
	struct list_head callback_head;
};

struct fiq_callback_node {
	struct list_head node;
	void (*callback)(unsigned int);
};

struct fiq_glue_handler {
	void (*fiq)(struct fiq_glue_handler *handler, void *regs);
	void *private;
};

struct fiq_func_params {
	struct fiq_glue_handler *h;
	void *regs;
};

extern struct fiq_private_data fiq_priv;

int fiq_glue_register_handler(const struct fiq_glue_handler *handler);
void fiq_glue_unregister_handler(void);

int fiq_first_register(void (*fiq_callback_func)(unsigned int),
	unsigned int fiq_num);
int fiq_more_register(void (*fiq_callback_func)(unsigned int),
	unsigned int fiq_num);
struct fiq_num_node *fiq_find_node(unsigned int fiq_num);
struct fiq_callback_node *fiq_find_callback(struct fiq_num_node *fiq_node,
	void (*fiq_callback_func)(unsigned int));
void fiq_free_callback(struct fiq_num_node *fiq_node);
int fiq_trigger(unsigned int cmd, struct pt_regs *regs);

extern struct mutex fiq_register_lock;
void proc_fiqstat_init(void);
#endif /* FIQ_GLUE_PRIVATE_H */
